/*
 * This file is part of Smart Route for S60 3rd Edition terminals
 * 
 * Copyright (C) 2006  Harri Salminen

 * This program free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 *(at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
 
#ifndef MAINSCREEN_H
#define MAINSCREEN_H

#include <coecntrl.h>		
#include <akniconutils.h>
#include <gulicon.h>
class MEikCommandObserver;		
class CAknSingleLargeStyleListBox;
class CEikTextListBox;

class CMainScreen : public CCoeControl
	{
public:
	CMainScreen();
	static CMainScreen* NewL( 
		const TRect& aRect, 
		const CCoeControl* aParent, 
		MEikCommandObserver* aCommandObserver );
	static CMainScreen* NewLC( 
		const TRect& aRect, 
		const CCoeControl* aParent, 
		MEikCommandObserver* aCommandObserver );        
	void ConstructL( 
		const TRect& aRect, 
		const CCoeControl* aParent, 
		MEikCommandObserver* aCommandObserver );
	virtual ~CMainScreen();

	TInt CountComponentControls() const;
	CCoeControl* ComponentControl( TInt aIndex ) const;
	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType );
	void HandleResourceChange( TInt aType );
	
	static void AddListBoxItemL( CEikTextListBox* aListBox, const TDesC& aString );
	static RArray< TInt >* GetSelectedListBoxItemsLC( CEikTextListBox* aListBox );
	static void DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox );
	static void CreateListBoxItemL( TDes& aBuffer, TInt aIconIndex,
			const TDesC& aMainText );
	CAknSingleLargeStyleListBox* ListBox();
	void AddListBoxResourceArrayItemL( TInt aResourceId, TInt aIconIndex );
	void DeleteListBoxSelectedItemsL();
	void SetupListBoxIconsL();
	static CGulIcon* LoadAndScaleIconL( const TDesC& aFileName, TInt aBitmapId, TInt aMaskId, TSize* aSize, TScaleMode aScaleMode );
	TBool HandleMarkableListCommandL( TInt aCommand );
	
	void SetupRunningL();
	void SetupPausedL();
	void SetupStoppedL();
	
protected:
	void SizeChanged();
	void ClearListL();
	
private:
	void Draw( const TRect& aRect ) const;
	void InitializeControlsL();
	void LayoutControls();
	CCoeControl* iFocusControl;
	MEikCommandObserver* iCommandObserver;
	CAknSingleLargeStyleListBox* iListBox;

protected: 
	enum TControls
	    {
		EListBox,
		ELastControl
	    };
	enum TListBoxImages
		{
		EListBoxSmartroute_mbmList_iconIndex = 0,
		EListBoxFirstUserImageIndex		
		};
	};
				
#endif // MAINSCREEN_H
